package data
{
	import control.manager.MapManager;
	
	import flash.geom.Point;

	/**
	 * 传送点信息 
	 * @author leo
	 * 
	 */
	public class ExitsData
	{
		/**
		 *  传送点名称
		 */		
		public var exitsName :String;
		/**
		 * 传送点位置 
		 */		
		public var exitsPoint :Point;
		/**
		 * 传送到下一个地图的id 
		 */		
		public var nextMapID :int;
		/**
		 * 下一个地图的人物出生点 
		 */		
		public var nextMapBornPoint :Point;
		/**
		 *  当前地图的ID 
		 */		
		public var curMapID :int;
		/**
		 * 上一个地图的ID 
		 */		
		public var lastMapID :int;
		public function ExitsData()
		{
		}
		/**
		 * 创建传送点列表 
		 * @param xmlList
		 * @return 
		 * 
		 */		
		public static function createExitsDataList(xmlList :XMLList):Vector.<ExitsData>
		{
			var exitsDataList :Vector.<ExitsData> = new Vector.<ExitsData>();
			if(xmlList)
			{
				for each(var xml :XML in xmlList.item)
				{
					var exitsData :ExitsData = new ExitsData();
					exitsData.exitsName = xml.@exitsName;
					exitsData.exitsPoint = MapManager.instance.string2Point(xml.@exitsPoint);
					exitsData.nextMapBornPoint = MapManager.instance.string2Point(xml.@nextMapBornPoint);
					exitsData.nextMapID = xml.@nextMapID;
					exitsData.curMapID = xml.@curMapID;
					exitsData.lastMapID = xml.@lastMapID;
					exitsDataList.push(exitsData);
				}
			}
			return exitsDataList;
		}
		
		public function get exitsPosition():Point
		{
			if(exitsPoint)
			{
				var mapData :MapData = MapManager.instance.curMapData;
				var p :Point = MapManager.instance.getPixelPoint(mapData.mapWalkGapWidth,mapData.mapWalkGapHeight,exitsPoint.x,exitsPoint.y);
				
				return p;
			}
			
			return null;
		}
	}
}